#pragma once

#include "Device.h"

namespace Graphics
{
	class Buffer;
	class RenderTexture;
}

namespace Graphics
{
class RenderTarget
{
private:
	struct VertexType
	{
		D3DXVECTOR3 Position;
		D3DXVECTOR4 Color;
		D3DXVECTOR2 Texture;
		D3DXVECTOR3 Normal;
	};

	struct InstanceType
	{
		D3DXVECTOR3 Position;
	};

public:
	RenderTarget(void);
	virtual ~RenderTarget(void);
	bool Initialize( int screenWidth, int screenHeight, int bitmapWidth, int bitmapHeight);
	void Deinitialize();
	bool Render(int positionX, int positionY);
	int GetIndexCount();
	int GetInstanceCount();
	RenderTexture* GetTexture();
	void SetAsTarget();

private:
	bool InitializeBuffers(D3DDevice* device);
	void DeinitializeBuffers();
	bool UpdateBuffers(D3DDevice* device, int positionX, int positionY);
	void RenderBuffers(D3DDevice* device);

private:
	RenderTexture* mRenderTexture;
	Buffer* mVertexBuffer; 
	Buffer* mIndexBuffer;
	Buffer* mInstanceBuffer;
	int mInstanceCount;
	int mVertexCount, mIndexCount;
	int mScreenWidth, mScreenHeight;
	int mBitmapWidth, mBitmapHeight;
	int mPreviousPosX, mPreviousPosY;
};
}